﻿// -----------------------------------------------------------------------
// <copyright file="AllBookFilter.cs" company="EPAM Systems">
////Copyright (c) EPAM Systems, 2012. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace MBOP.Domain.Filters
{
	#region Usings

	using System;
	using System.Linq.Expressions;

	using MBOP.Core.Entities.Library;
	using MBOP.Core.Interfaces.Common;

	#endregion

	/// <summary>
	/// Provides filtering condition for all books.
	/// </summary>
	public class AllBookFilter : IFilter<Book>
	{
		#region Private Fields

		/// <summary>
		/// Represents the filter condition.
		/// </summary>
		private Expression<Func<Book, bool>> _filterCondition;

		#endregion

		#region IFilter<Book> Implementation

		/// <summary>
		/// Gets the filter condition.
		/// </summary>
		public Expression<Func<Book, bool>> FilterCondition
		{
			get 
			{
				if (this._filterCondition == null)
				{
					this._filterCondition = book => true;
				}

				return this._filterCondition;
			}
		}

		#endregion
	}
}
